package com.snj.visangedu.studytime;

import java.util.ArrayList;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.TextView;

import com.snj.visangedu.R;


public class BellAdapter extends BaseAdapter {
	
	String tag = "BellAdapter";
	
	
	
	String packagename = "";
	Context context;
	int layout;
	
	
	ArrayList<BellItem> mBellList;
	
	LayoutInflater mInflater = null;
	
	public BellAdapter(Context _context, int _layout, ArrayList<BellItem> _belllist, String pkgname) {
		// TODO Auto-generated constructor stub
		
		this.context = _context;
		this.layout = _layout;
		this.mBellList = _belllist;
		
	}
	
	public void Insert(ArrayList<BellItem> mList)
	{
		mBellList.addAll(mList);
	}
	
	public void SetList(ArrayList<BellItem> mList)
	{
		mBellList = mList;
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return mBellList.size();
	}

	public BellItem getItem(int position) {
		// TODO Auto-generated method stub
		return mBellList.get(position);
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	
	public View getView(final int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
	
		BellHolder holder = null;
		
		int no = 0;
		long rh = 0, rm = 0, rs = 0, rms = 0;
		long eh = 0, em = 0, es = 0, ems = 0;
		
		
		if(convertView == null)
		{
			mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = mInflater.inflate(layout, parent, false);
			
			holder = new BellHolder();
			
			holder.blly_layout = (BellLayout)convertView.findViewById(R.id.blly_layout);
			holder.txt_bellname = (TextView)convertView.findViewById(R.id.txt_bell);
			holder.rdo_bell = (RadioButton)convertView.findViewById(R.id.rdo_bell);
			
			convertView.setTag(holder);
			
			
		}
		else
		{
			holder = (BellHolder)convertView.getTag();
		}
		
		no = mBellList.get(position).GetNo();		
		holder.txt_bellname.setText(mBellList.get(position).GetBellName());
		
		Log.d(tag, position + " : " + mBellList.get(position).GetChecked());
		/*
		if(mBellList.get(position).GetChecked()){
			if(holder.blly_layout.checkable == null)
			{
				while(holder.blly_layout.checkable == null){
					try {
						Thread.sleep(1000);
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					Log.d(tag, "wait...");
				}
			}
		}*/
		holder.rdo_bell.setChecked(mBellList.get(position).GetChecked());
		holder.rdo_bell.setChecked(mBellList.get(position).GetChecked());
		holder.rdo_bell.setChecked(mBellList.get(position).GetChecked());
		holder.rdo_bell.setChecked(mBellList.get(position).GetChecked());
		holder.rdo_bell.setChecked(mBellList.get(position).GetChecked());
		holder.rdo_bell.setChecked(mBellList.get(position).GetChecked());
		holder.rdo_bell.setChecked(mBellList.get(position).GetChecked());
		holder.rdo_bell.setChecked(mBellList.get(position).GetChecked());
		holder.rdo_bell.setChecked(mBellList.get(position).GetChecked());
		holder.rdo_bell.setChecked(mBellList.get(position).GetChecked());
		
		
		return convertView;
	}
	
	
}
